package Pages;

import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;

public class SchedulePage extends HomePage {
    //选择日期
    public SchedulePage pickDate(){
        //点击选择日期,12号为例
        driver.findElement(By.cssSelector(".dateItem:nth-child(14)")).click();
        return this;
    }

    //添加排班
    public SchedulePage addSchedule(){

        return this;
    }

    //移除排班
    public SchedulePage removeSchedule(){

        return this;
    }

    public SchedulePage clickCounselorTab(){
        //选择咨询师tab
        waitForWindow(2000);
        driver.findElement(By.cssSelector(".leftActive > .el-col:nth-child(2)")).click();
        return this;
    }
    public SchedulePage clickSupervisorTab(){
        //选择督导tab
        waitForWindow(2000);
        driver.findElement(By.cssSelector(".leftActive > .el-col:nth-child(2)")).click();
        return this;
    }

    //点击添加督导/咨询师
    public SchedulePage clickAdd(){
       waitForWindow(2000);
        driver.findElement(By.cssSelector(".rightList > .el-row:nth-child(3)")).click();
        return this;
    }


    //点击移除督导/咨询师
    public SchedulePage clickRemove(){
        waitForWindow(2000);
        //点击移除
        driver.findElement(By.cssSelector(".el-row:nth-child(1) > .el-col:nth-child(3)")).click();
        return this;
    }

    //点击下拉框 drop down
    public SchedulePage dropDownSelect(){
        waitForWindow(2000);
        driver.findElement(By.xpath("//input[@type='text']")).click();
        return this;
    }

    //收回下拉框
    public SchedulePage packUpSelect(){
        dropDownSelect();
        driver.findElement(By.cssSelector(".el-select__input")).click();
        return this;
    }

    //督导单选，test3为例
    public SchedulePage singleSelect(){
        waitForWindow(2000);
        driver.findElement(By.xpath("//li[contains(.,'test3')]")).click();
        return this;
    }

    //督导多选，test1 test2为例
    public SchedulePage multiSelect(){
        waitForWindow(2000);
        driver.findElement(By.xpath("//li[contains(.,'test1')]")).click();
        driver.findElement(By.xpath("//li[contains(.,'test2')]")).click();
        return this;
    }

    //咨询师单选，test4为例
    public SchedulePage singleSelect1(){
        waitForWindow(2000);
        driver.findElement(By.xpath("//li[contains(.,'test4')]")).click();
        return this;
    }

    //咨询师多选，test5 test6为例
    public SchedulePage multiSelect1(){
        waitForWindow(2000);
        driver.findElement(By.xpath("//li[contains(.,'test5')]")).click();
        driver.findElement(By.xpath("//li[contains(.,'test6')]")).click();
        return this;
    }

    public SchedulePage confirm(){
        waitForWindow(2000);
        driver.findElement(By.cssSelector(".el-button--default:nth-child(2)")).click();
        return this;
    }

    public SchedulePage cancel(){
        waitForWindow(2000);
        driver.findElement(By.cssSelector(".el-button--default:nth-child(1)")).click();
        return this;
    }

    public SchedulePage dialogConfirm(){
        waitForWindow(2000);
        driver.findElement(By.xpath("//button[contains(.,'确定')]")).click();
        return this;
    }

    public SchedulePage dialogCancel(){
        waitForWindow(2000);
        driver.findElement(By.xpath("//button[contains(.,'取消')]")).click();
        return this;
    }
    //督导值班列表个数

    public int getNum(){
        waitForWindow(2000);
        WebElement element = driver.findElement(By.cssSelector("div.dateItem:nth-child(14) > span:nth-child(3) > span:nth-child(1)"));
        String info = element.getText();
        int num = Integer.parseInt(info);
        return num;
    }

    //咨询师值班列表个数

    public int getNum1(){
        waitForWindow(2000);
        WebElement element = driver.findElement(By.cssSelector(".dateItem:nth-child(14) > .watcher:nth-child(2) > span"));
        String info = element.getText();
        int num = Integer.parseInt(info);
        return num;
    }

    //返回当天值班的咨询师/督导列表，咨询师和督导均可由此返回列表值
    public String getList(){
        waitForWindow(2000);
        WebElement element = driver.findElement(By.cssSelector(".userList"));
        String info = element.getText();
        return info;
    }



}
